<?php

namespace App\Controller\Restful;

use App\Restful\RestfulInterface;
use Yolo\Rpc\Annotations\Restful;
use Yolo\Rpc\Annotations\RpcController;
use Yolo\Rpc\Enums\HttpMethod;
use Yolo\Service\RpcRequest;

#[RpcController]
class RestfulController implements RestfulInterface
{
    #[Restful(HttpMethod::GET, 'base/restful', [])]
    public function restful(): array
    {
        return  [
            'message' => 'Hello World!',
        ];
    }

    #[Restful(HttpMethod::GET, 'base/users/{id}', [
        'validation' => [
            'path' => [
                'id' => 'required',
            ]
        ]
    ])]
    public function restfulWithPathArgs(RpcRequest $request): array
    {
        $path = $request->getPathArguments();
        $qs = $request->getQueryArguments();
        return  [
            'message' => 'Hello World!',
            'path' => $path,
            'qs' => $qs,
        ];
    }
}
